package com.topboya.linker.ui.activity;

import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.topboya.linker.R;
import com.topboya.linker.ui.base.activity.BaseActivity;
import com.topboya.linker.ui.presenter.LoginAtPresenter;
import com.topboya.linker.ui.view.ILoginAtView;

public class LoginActivity extends BaseActivity<ILoginAtView, LoginAtPresenter> implements ILoginAtView {

    private EditText et_phone;
    private EditText et_ps;
    private EditText et_code;
    private Button btn_login;
    private ImageView img_code;
    private RelativeLayout rl_login_code;
    private int loginCount=1;

    @Override
    protected int getLayoutId() {

        return R.layout.activity_login;
    }

    @Override
    protected void initView() {
        loginCount=1;
        et_phone = findViewById(R.id.et_phone);
        et_ps = findViewById(R.id.et_ps);
        btn_login = findViewById(R.id.btn_login);
        img_code = findViewById(R.id.img_code);
        et_code = findViewById(R.id.et_code);
        rl_login_code = findViewById(R.id.rl_login_code);
    }

    @Override
    protected void initData() {

//        mPresenter.login();
    }

    @Override
    protected void initListener() {

        btn_login.setOnClickListener(listener -> {
            loginCount++;
            mPresenter.login(loginCount);

                });


    }

    @Override
    protected LoginAtPresenter createPresenter() {

        return new LoginAtPresenter(this);
    }


    @Override
    public EditText getEtPhone() {

        return et_phone;
    }

    @Override
    public EditText getEtPwd() {

        return et_ps;
    }

    @Override
    public EditText getEtCode() {

        return et_code;
    }

    @Override
    public ImageView getImgCode() {

        return img_code;
    }

    @Override
    public RelativeLayout getLinearCode() {

        return rl_login_code;
    }

//    @Override
//    public void onBackPressed() {
//
//        back();
//    }
//
//    @Override
//    public boolean onKeyDown(int keyCode, KeyEvent event) {
//        // 是否触发按键为back键
//        if (keyCode == KeyEvent.KEYCODE_BACK) {
//            onBackPressed();
//            return true;
//        } else { // 如果不是back键正常响应
//            return super.onKeyDown(keyCode, event);
//        }
//    }
//
//    private void back() {
//
//        System.exit(0);
//
//    }
}
